//初始化分页层
function initPageBottom(_page, _pagesize, _nextpage, _prepage, _totalpages){	
	$("#fenyema p").empty();//清空原始数据
	var pBodyStr = "";
	pBodyStr+="<a href=\"#\" id=\"fir\" onclick=\"findBlackData(1,"+_pagesize+",\'1\')\">首页</a>";
	pBodyStr+="<a href=\"#\" id=\"pre\" onclick=\"findBlackData("+_prepage+","+_pagesize+",\'"+_prepage+"\')\">上一页</a>";	
	if(_totalpages>=5&&_page>=3 && (_page+2)<=_totalpages){
		var page_2=_page-2;
		var page_1=_page-1;
		var page1=_page+1;
		var page2=_page+2;		
		pBodyStr+="<a href=\"#\" id=\"a"+page_2+"\" onclick=\"findBlackData("+page_2+","+_pagesize+",this.id)\">"+page_2+"</a>";
		pBodyStr+="<a href=\"#\" id=\"a"+page_1+"\" onclick=\"findBlackData("+page_1+","+_pagesize+",this.id)\">"+page_1+"</a>";
		pBodyStr+="<a href=\"#\" id=\"a"+_page+"\" onclick=\"findBlackData("+_page+","+_pagesize+",this.id)\">"+_page+"</a>";		
		pBodyStr+="<a href=\"#\" id=\"a"+page1+"\" onclick=\"findBlackData("+page1+","+_pagesize+",this.id)\">"+page1+"</a>";
		pBodyStr+="<a href=\"#\" id=\"a"+page2+"\" onclick=\"findBlackData("+page2+","+_pagesize+",this.id)\">"+page2+"</a>";		
	}else if(_totalpages>=5&&_page==2){
		var page_1=_page-1;
		var page1=_page+1;
		var page2=_page+2;
		var page3=_page+3;		
		pBodyStr+="<a href=\"#\" id=\"a"+page_1+"\" onclick=\"findBlackData("+page_1+","+_pagesize+",this.id)\">"+page_1+"</a>";
		pBodyStr+="<a href=\"#\" id=\"a"+_page+"\" onclick=\"findBlackData("+_page+","+_pagesize+",this.id)\">"+_page+"</a>";		
		pBodyStr+="<a href=\"#\" id=\"a"+page1+"\" onclick=\"findBlackData("+page1+","+_pagesize+",this.id)\">"+page1+"</a>";
		pBodyStr+="<a href=\"#\" id=\"a"+page2+"\" onclick=\"findBlackData("+page2+","+_pagesize+",this.id)\">"+page2+"</a>";
		pBodyStr+="<a href=\"#\" id=\"a"+page3+"\" onclick=\"findBlackData("+page3+","+_pagesize+",this.id)\">"+page3+"</a>";	
	}else if(_totalpages>=5&&(_totalpages - _page)==1){
		var page_3=_page-3;
		var page_2=_page-2;
		var page_1=_page-1;
		var page1=_page+1;			
		pBodyStr+="<a href=\"#\" id=\"a"+page_3+"\" onclick=\"findBlackData("+page_3+","+_pagesize+",this.id)\">"+page_3+"</a>";
		pBodyStr+="<a href=\"#\" id=\"a"+page_2+"\" onclick=\"findBlackData("+page_2+","+_pagesize+",this.id)\">"+page_2+"</a>";
		pBodyStr+="<a href=\"#\" id=\"a"+page_1+"\" onclick=\"findBlackData("+page_1+","+_pagesize+",this.id)\">"+page_1+"</a>";
		pBodyStr+="<a href=\"#\" id=\"a"+_page+"\" onclick=\"findBlackData("+_page+","+_pagesize+",this.id)\">"+_page+"</a>";		
		pBodyStr+="<a href=\"#\" id=\"a"+page1+"\" onclick=\"findBlackData("+page1+","+_pagesize+",this.id)\">"+page1+"</a>";		
	}else if(_totalpages>=5&&_totalpages == _page){
		var page_4=_page-4;
		var page_3=_page-3;
		var page_2=_page-2;
		var page_1=_page-1;		
		pBodyStr+="<a href=\"#\" id=\"a"+page_4+"\" onclick=\"findBlackData("+page_4+","+_pagesize+",this.id)\">"+page_4+"</a>";
		pBodyStr+="<a href=\"#\" id=\"a"+page_3+"\" onclick=\"findBlackData("+page_3+","+_pagesize+",this.id)\">"+page_3+"</a>";
		pBodyStr+="<a href=\"#\" id=\"a"+page_2+"\" onclick=\"findBlackData("+page_2+","+_pagesize+",this.id)\">"+page_2+"</a>";
		pBodyStr+="<a href=\"#\" id=\"a"+page_1+"\" onclick=\"findBlackData("+page_1+","+_pagesize+",this.id)\">"+page_1+"</a>";
		pBodyStr+="<a href=\"#\" id=\"a"+_page+"\" onclick=\"findBlackData("+_page+","+_pagesize+",this.id)\">"+_page+"</a>";			
	}else{
		if(_totalpages>=5){
			for (var i=0;i<5;i++){
				if(_page > _totalpages){
					break;
				}
				pBodyStr+="<a href=\"#\" id=\"a"+_page+"\" onclick=\"findBlackData("+_page+","+_pagesize+",this.id)\">"+_page+"</a>";
				_page++;
			}			
		}else{
			if(_totalpages==1){
				pBodyStr+="<a href=\"#\" id=\"a1\" onclick=\"findBlackData(1,"+_pagesize+",this.id)\">1</a>";
				
			}else if(_totalpages==2){
				pBodyStr+="<a href=\"#\" id=\"a1\" onclick=\"findBlackData(1,"+_pagesize+",this.id)\">1</a>";
				pBodyStr+="<a href=\"#\" id=\"a2\" onclick=\"findBlackData(2,"+_pagesize+",this.id)\">2</a>";
			}else if(_totalpages==3){
				pBodyStr+="<a href=\"#\" id=\"a1\" onclick=\"findBlackData(1,"+_pagesize+",this.id)\">1</a>";
				pBodyStr+="<a href=\"#\" id=\"a2\" onclick=\"findBlackData(2,"+_pagesize+",this.id)\">2</a>";
				pBodyStr+="<a href=\"#\" id=\"a3\" onclick=\"findBlackData(3,"+_pagesize+",this.id)\">3</a>";
			}else if(_totalpages==4){
				pBodyStr+="<a href=\"#\" id=\"a1\" onclick=\"findBlackData(1,"+_pagesize+",this.id)\">1</a>";
				pBodyStr+="<a href=\"#\" id=\"a2\" onclick=\"findBlackData(2,"+_pagesize+",this.id)\">2</a>";
				pBodyStr+="<a href=\"#\" id=\"a3\" onclick=\"findBlackData(3,"+_pagesize+",this.id)\">3</a>";
				pBodyStr+="<a href=\"#\" id=\"a4\" onclick=\"findBlackData(4,"+_pagesize+",this.id)\">4</a>";
			}						
		}	
	}	
	pBodyStr+="<a href=\"#\" id=\"next\" onclick=\"findBlackData("+_nextpage+","+_pagesize+",\'a"+_nextpage+"\')\">下一页</a>";
	pBodyStr+="<a href=\"#\" id=\"last\" onclick=\"findBlackData("+_totalpages+","+_pagesize+",\'a"+_totalpages+"\')\">尾页</a>";
	pBodyStr+="<span href=\"#\">跳到<input type=\"text\" class=\"tiandaoye\" onkeypress=\"if(event.keyCode==13){skippage("+_totalpages+",this.value,"+_pagesize+",this.value);}\"/>页/共"+_totalpages+"页</span>";
	$("#fenyema p").html(pBodyStr);
}

function bottomcolor(_aid){
	if(_aid.indexOf("a") >= 0){
		$("#"+_aid).css("background","#7ebc00");
	}else{
		$("#a"+_aid).css("background","#7ebc00");
	}
}

function skippage(_totalpages,_page,_pagesize,aid){	
	if(_page>_totalpages){
		findBlackData(_totalpages,_pagesize,""+_totalpages);
	}else if(_page<=0){
		findBlackData(1,_pagesize,"1");
	}else{
		findBlackData(_page,_pagesize,aid);
	}
}
